package structure.concrete;

import structure.interfaces.IOperatorBinary;

/**
 * this class represent the divide operator in the chromosome
 * the class implements INode interface and therefore functions 
 * documentation can be found inside INode.java
 */
public class Divide extends IOperatorBinary {

	@Override
	public double getValue(double x) {
		double divisor = right.getValue(x);
		if (divisor == 0)
		{
			return 0;
		}
		else
		{
			return left.getValue(x) / divisor;
		}
	}

	@Override
	public String getDescription() {
		return "(" + left.getDescription() + "/" + right.getDescription() + ")";
	}

	public Divide clone() {
		Divide operator = new Divide();
		operator.setLeft(left.clone());
		operator.setRight(right.clone());
		return operator;
	}
	
}
